/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package control;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Agenda;
import model.AgendaDAO;
import model.Pessoa;
import model.Profissional;

/**
 *
 * @author Eduarda
 */
public class TrataUpdateAgenda extends Comando{

    @Override
    public void executar(HttpServletRequest request, HttpServletResponse response) throws ClassNotFoundException, SQLException, IOException, ServletException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            response.setContentType("text/html");
            
            int profissional = Integer.parseInt(request.getParameter("profissional"));
            int idAgenda = Integer.parseInt(request.getParameter("idAgenda"));
            Agenda ag = new Agenda();
            Pessoa pes  = new Pessoa(profissional, null, null, null, null, null, null, null, null);
            Profissional prof = new Profissional(pes, 0, null, 0, null, null, null, null, null, null, null, null, null, null, null);
            ag.setIdAgenda(idAgenda);
            ag.setProfissional(prof);
            new AgendaDAO().editar(ag);
          
                
                
          //  HttpSession session = request.getSession(false);
            //session.setAttribute("Profissi", coord);
            //session.setAttribute("editado", coo);
            
            response.sendRedirect("agendaEditada.jsp");  
        } catch (SQLException ex) {
            throw new ServletException(ex);
        } 
    }
    
}
